<template>
	<view>
		<uni-nav-bar fixed="true" @clickLeft="back" backgroundColor="#6869a8" height="120rpx" statusBar="true">
			<view style="font-size: 37rpx; margin: auto;">
				<text style="color: #FFF;">群列表</text>
			</view>
			<view slot="left">
				<uni-icons type="back" size="30" color="#FFF"></uni-icons>
			</view>
		</uni-nav-bar>
		<view class="">
			<qun-enIndex :key="timer" ref="qun" :original="groups" @press="toGroup"></qun-enIndex>
		</view>
		<view class="tip" v-if="groups.length === 0">
			没有加入的群聊~~
		</view>
	</view>
</template>

<script>
	import QunEnIndex from "@/components/qun-enIndex/qun-enIndex.vue"
	export default {
		components: {
			QunEnIndex
		},
		data() {
			return {
				groups: [],
				timer: 0
			}
		},
		mounted() {
			this.$request.TokenRequest({
				url: "/group/getMyGroup"
			}, {}).then(res => {
				if (res.state === 200) {
					this.groups = res.data
					this.timer = new Date().getTime()
					// console.log(this.groups)
				} else {
					uni.showToast({
						icon: "none",
						title: res.message
					})
				}
			})
		},
		methods: {
			back() {
				uni.navigateBack({})
			},
			toGroup(group) {
				console.log("toGroup:" + group.id)
				uni.navigateTo({
					url: "../groupInfo/groupInfo?gid=" + group.id + "&groupName=" + group.groupName
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tip {
		font-size: 30rpx;
		color: #858786;
		text-align: center;
		padding: 40rpx 0;
	}
</style>
